%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/conditions/complex-filter-via-partial-variables"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 10, 13, 14, 24, 26, 47, 48, 9, 15, 17, 23, 33, 37, 8, 18<br />2: PgSelectInlineApply[43]<br />3: PgSelect[12]<br />ᐳ: Access[44]<br />4: PgSelectRows[19]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 44<br /><br />ROOT __Item{1}ᐸ19ᐳ[20]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 21, 44, 20<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[21]<br />1: <br />ᐳ: 22, 45, 46<br />2: PgSelectRows[38]"):::bucket
    Bucket3("Bucket 3 (listItem)<br /><br />ROOT __Item{3}ᐸ38ᐳ[39]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 40<br /><br />ROOT PgSelectSingle{3}ᐸmessagesᐳ[40]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket4

    %% plan dependencies
    PgSelect12[["PgSelect[12∈0] ➊<br />ᐸforumsᐳ"]]:::plan
    Object15{{"Object[15∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Lambda17{{"Lambda[17∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'INHERIT' ]ᐳ[47]"}}:::plan
    ApplyInput18{{"ApplyInput[18∈0] ➊"}}:::plan
    PgSelectInlineApply43["PgSelectInlineApply[43∈0] ➊"]:::plan
    Object15 & Lambda17 & ApplyInput18 & PgSelectInlineApply43 --> PgSelect12
    Access13{{"Access[13∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access14{{"Access[14∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access13 & Access14 --> Object15
    __InputObject23{{"__InputObject[23∈0] ➊"}}:::plan
    Access24{{"Access[24∈0] ➊<br />ᐸ0.featuredᐳ"}}:::plan
    Access26{{"Access[26∈0] ➊<br />ᐸ0.isArchivedᐳ"}}:::plan
    Access24 & Access26 --> __InputObject23
    ApplyInput33{{"ApplyInput[33∈0] ➊"}}:::plan
    Lambda37{{"Lambda[37∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[48]"}}:::plan
    ApplyInput33 & Lambda37 --> PgSelectInlineApply43
    __InputObject8{{"__InputObject[8∈0] ➊"}}:::plan
    __InputObject9{{"__InputObject[9∈0] ➊"}}:::plan
    __InputObject9 --> __InputObject8
    Access10{{"Access[10∈0] ➊<br />ᐸ0.someᐳ"}}:::plan
    Access10 --> __InputObject9
    __Value0["__Value[0∈0] ➊<br />ᐸvariableValuesᐳ"]:::plan
    __Value0 --> Access10
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access13
    __Value2 --> Access14
    __InputObject8 --> ApplyInput18
    PgSelectRows19[["PgSelectRows[19∈0] ➊"]]:::plan
    PgSelect12 --> PgSelectRows19
    __Value0 --> Access24
    __Value0 --> Access26
    __InputObject23 --> ApplyInput33
    Access44{{"Access[44∈0] ➊<br />ᐸ12.m.subqueryDetailsFor29ᐳ"}}:::plan
    PgSelect12 --> Access44
    __Item20[/"__Item[20∈1]<br />ᐸ19ᐳ"\]:::itemplan
    PgSelectRows19 ==> __Item20
    PgSelectSingle21{{"PgSelectSingle[21∈1]<br />ᐸforumsᐳ"}}:::plan
    __Item20 --> PgSelectSingle21
    List45{{"List[45∈2]<br />ᐸ44,20ᐳ"}}:::plan
    Access44 & __Item20 --> List45
    PgClassExpression22{{"PgClassExpression[22∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
    PgSelectSingle21 --> PgClassExpression22
    PgSelectRows38[["PgSelectRows[38∈2]"]]:::plan
    Lambda46{{"Lambda[46∈2]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda46 --> PgSelectRows38
    List45 --> Lambda46
    __Item39[/"__Item[39∈3]<br />ᐸ38ᐳ"\]:::itemplan
    PgSelectRows38 ==> __Item39
    PgSelectSingle40{{"PgSelectSingle[40∈3]<br />ᐸmessagesᐳ"}}:::plan
    __Item39 --> PgSelectSingle40
    PgClassExpression41{{"PgClassExpression[41∈4]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle40 --> PgClassExpression41
    PgClassExpression42{{"PgClassExpression[42∈4]<br />ᐸ__messages__.”featured”ᐳ"}}:::plan
    PgClassExpression41 o--o PgClassExpression42

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value0,__Value2,__InputObject8,__InputObject9,Access10,PgSelect12,Access13,Access14,Object15,Lambda17,ApplyInput18,PgSelectRows19,__InputObject23,Access24,Access26,ApplyInput33,Lambda37,PgSelectInlineApply43,Access44 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item20,PgSelectSingle21 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression22,PgSelectRows38,List45,Lambda46 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item39,PgSelectSingle40 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgClassExpression41,PgClassExpression42 bucket4

